const log = require('j7/log');
const bcutils = require('j7/bcutils');
const utils = require('j7/utils');
const bcconst = require('common/bcconst');
const BaseEventProcess = require('../common/BaseEventProcess');
const metaFactory = require('../../../metadata/factory');

class Transfer extends BaseEventProcess {

  async start() {
    const returnValues = this.getReturnValues();
    const from = bcutils.toNormalAddress(returnValues['from']);
    const to = bcutils.toNormalAddress(returnValues['to']);
    const tokenId = returnValues['tokenId'];

    await this.mustBeMint(to, tokenId, bcconst.BC_NFT_GOLD_BULLION);
    if (bcutils.isSysAddress(from)) {
      await this.ingameActivate(from, to, tokenId, bcconst.BC_NFT_GOLD_BULLION);
    } else {
      await this.add721NftRefresh
      (
        this.getNetId(),
        this.getContractAddress(),
        this.getContractName(),
        tokenId
      );
    }
    await this.update721NftOwner(tokenId, this.getContractAddress(), to, from);
    await this.markOk();
  }

}

module.exports = Transfer;
